﻿using Microsoft.AspNetCore.Mvc;
using PHMEE.Controllers;
using PHMEE.EnergyEfficiency;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace PHMEE
{
    /// <summary>
    /// 实时数据控制器
    /// </summary>
    [Route("api/RealTime")]
    public class RealTimeController : PHMEEController
    {
        private readonly IRealTimeAppService realTimeAppService;
        private readonly IFlowmeterExportAppService _exportAppService;

        public RealTimeController(IRealTimeAppService realTimeAppService, IFlowmeterExportAppService exportAppService)
        {
            this.realTimeAppService = realTimeAppService;
            _exportAppService = exportAppService;
        }
        /// <summary>
        /// 船端获取实时的GPS数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [Route("GpsRealTimeData")]
        public async Task<GpsRealtimeDto> GpsRealTimeData()
        {
            return await realTimeAppService.GetGpsCacheDataAsync();
        }
        /// <summary>
        /// 获取所有流量计数据
        /// </summary>
        /// <param name="VesselId">船舶ID</param>
        /// <param name="onVessel">船端或者岸端</param>
        /// <returns>返回所有流量计数据</returns>
        [HttpGet]
        [Route("GetFlowmeterData")]
        public async Task<List<MassFlowmeterDto>> GetFlowmeterData(Guid VesselId, bool onVessel)
        {
            return await realTimeAppService.GetFlowmeterDataAsync(VesselId, onVessel);
        }

        /// <summary>
        /// 获取主机，副机，锅炉等油耗
        /// </summary>
        /// <param name="VesselId"></param>
        /// <returns></returns>
        [HttpGet]
        [Route("GetOilFuelData")]
        public async Task<List<DeviceFuelConsumptionDto>> GetOilFuelData(Guid VesselId)
        {
            return await realTimeAppService.GetOilFuelDataAsync(VesselId);
        }
    }
}
